package com.my.attendance.dao;

import com.my.attendance.entity.Position;
import com.my.attendance.util.BaseDAO;

import java.util.List;

public class ZhiChengDao extends BaseDAO {
    public List<Position> ListZhiCheng() throws Exception {
        String sql="select * from position";
         return getList(sql, new Position(),new Object[0]);
    }

    public void addPos(Position p) throws Exception {
        String sql="insert into Position values (null,?,?,?,?)";
        Object[] obj={p.getPosition_number(),p.getName(),p.getLevel(),p.getNotes()};
        addOrupdOrdel(sql,obj);
    }

    public String addPosPre() throws Exception {
        String sql="select Max(position_number) from position;";
        String str ="Max(position_number)";
        return getString(sql,str);
    }

    public void del(String position_number) throws Exception {
        String sql="delete from Position where position_number=?";
        Object[] obj={position_number};
        addOrupdOrdel(sql,obj);
    }

    public void update(Position p) throws Exception {
        String sql="update Position set name=?,level=?,notes=? where position_number=?";
        Object[] obi={p.getName(),p.getLevel(),p.getNotes(),p.getPosition_number()};
        addOrupdOrdel(sql,obi);
    }

    public Position getZhiCheng(String position_number) throws Exception {
        String sql="select * from position where position_number=?;";
        Object[] obj = {position_number};
        return getOne(sql,new Position(),obj);
    }
}
